<?php
/**
 * jishupu-cms
 * @Author:技术铺<jishupu@qq.com>
 * @Date: 2022/3/31
 */

namespace App\Http\Middleware;

use App\Services\ViewLogService;
use Closure;
use Illuminate\Http\Request;

/**
 * 访问记录
 * Class ViewLog
 * @package App\Http\Middleware
 */
class ViewLog
{
    /**
     * @param Request $request
     * @param Closure $next
     * @param $type // 应用类型：1电脑网站、2微信公众号、3微信小程序、4app 默认：1
     * @return mixed
     */
    public function handle(Request $request, Closure $next, $type = 1)
    {
        $response = $next($request);
        ViewLogService::addViewLogRecord($type);
        return $response;
    }
}
